<?php @session_start();?>
<?php
require_once('./safe.php');
require_once('../admin/config.php');
$conn = mysql_connect($cfg_dbhost,$cfg_dbuser,$cfg_dbpwd);
mysql_select_db($cfg_dbname,$conn);
function imgtobase64($img='', $imgHtmlCode=true)
{
$imageInfo = getimagesize($img);
$base64 = "" . chunk_split(base64_encode(file_get_contents($img)));
return 'data:' . $imageInfo['mime'] . ';base64,' . chunk_split(base64_encode(file_get_contents($img)));
}
 header("Content-type:application/json");
$sqla="select * from ph_myapp where userid='".$_SESSION["userid"]."'";
$resulta=mysql_query($sqla);
$str1='[';
while($rowa=mysql_fetch_array($resulta)){
$iia='apple_black.png';
if($rowa["thetype"]=="google"){
    $iia='android_black.png';
}
//$str.= '{"id":'.$rowa["ID"].',"customer_id":"'.$_SESSION["userid"].'","package":"284882215","name":"'.$rowa["app_name"].'","icon":"'.str_replace('"','',json_encode(imgtobase64($rowa["icon"]))).'","type":"0","status":"1","app_store_id":"2","app_store":{"id":2,"internal_name":"app_store","name":"Apple App Store","icon":"apple_black.png","external_app_store_id":"2","created_at":"2020-01-23T15:56:35.000000Z","updated_at":"2020-01-23T15:56:35.000000Z","deleted_at":null,"isAppStore":true,"isGooglePlay":false}},';
$str.= '{"id":'.$rowa["ID"].',"customer_id":"'.$_SESSION["userid"].'","package":"284882215","name":"'.$rowa["app_name"].'","icon":"'.$rowa["icon"].'","type":"0","status":"1","app_store_id":"2","app_store":{"id":2,"internal_name":"app_store","name":"Apple App Store","icon":"'.$iia.'","external_app_store_id":"2","created_at":"2020-01-23T15:56:35.000000Z","updated_at":"2020-01-23T15:56:35.000000Z","deleted_at":null,"isAppStore":false,"isGooglePlay":true}},';
}

 $str2=']';
 $str3=substr($str,0,strlen($str)-1);

 echo $str1.$str3.$str2;
?>